/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.ds2.bl;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.itsc.ds2.dao.SaleDetailsDaoLocal;
import mx.itsc.ds2.enumerations.TransactionStatus;
import mx.itsc.ds2.model.SaleDetails;
import mx.itsc.ds2.model.Sales;

/**
 *
 * @author Eli
 */
@Stateless
public class SaleDetailBl implements SaleDetailBlLocal {
    @EJB
    private SaleDetailsDaoLocal saleDetailsDao;
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public TransactionStatus register(List<SaleDetails> detailList, Sales sale, SaleDetails saleDetail) {
        for (SaleDetails sailDetails : detailList) {
            if(!detailList.isEmpty()&& sale.getIdsale()!=null){
            saleDetailsDao.create(saleDetail);
            return TransactionStatus.COMPLETE;
            }else{
            return TransactionStatus.INCOMPLETE;
            }
        }return TransactionStatus.COMPLETE;
    }

    @Override
    public List<SaleDetails> getAll() {
        return saleDetailsDao.findAll();
    }

    
}
